import tkinter as tk
from tkinter import filedialog

# 选择文件夹
def folder_address():
    root = tk.Tk()
    root.withdraw()

    Folderpath = filedialog.askdirectory()
    root.destroy()
    return Folderpath

# 选择文件
def file_address():
    root = tk.Tk()
    root.withdraw()
    Filepath = filedialog.askopenfilename()
    root.destroy()
    return Filepath

# 判断字符在字符串中最后一次出现的索引位置
def find_last(string,str):
    last_position=-1
    while True:
        position=string.find(str,last_position+1)
        last_position = last_position + 1
        if position==-1:
            return last_position